﻿using SF.Common;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SF.Ucenter.admin.finance
{
    public partial class business_dialog_print : System.Web.UI.Page
    {
        protected int business_settlement_id = 0;
        protected Model.sf_business_settlement model = new Model.sf_business_settlement();
        protected void Page_Load(object sender, EventArgs e)
        {
            this.business_settlement_id = int.Parse(DTRequest.GetQueryString("id"));
            model = new BLL.sf_business_settlement().GetModel(this.business_settlement_id);


            if (!IsPostBack)
            {
                RptBind(" sf_finance_settlement_num = '" + model.sf_finance_settlement_num + "' and busnieseNum = '" + model.busnieseNum + "' and id>0", "id desc");
            }
        }

        #region 数据绑定=================================
        private void RptBind(string _strWhere, string _orderby)
        {
            BLL.sf_businessapp_settlement bll = new BLL.sf_businessapp_settlement();
            this.rptList.DataSource = bll.GetListByPage(_strWhere, "", 0, 10);
            this.rptList.DataBind();
        }
        #endregion

        #region 嵌套订单数据绑定
        protected void rptList_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            //判断里层repeater处于外层repeater的哪个位置（ AlternatingItemTemplate，FooterTemplate，HeaderTemplate，，ItemTemplate，SeparatorTemplate）
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater rep = e.Item.FindControl("rpOrderlist") as Repeater;//找到里层的repeater对象
                DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 

                string settleNum = rowv["sf_finance_settlement_num"].ToString();
                string appNum = rowv["appNum"].ToString();

                BLL.sf_ordersettlement bll = new BLL.sf_ordersettlement();
                rep.DataSource = bll.GetList(" sf_finance_settlement_num = '" + settleNum + "' and appNum = '"+appNum+"' ");
                rep.DataBind();
            }
        }

        #endregion
    }
}